<template>
	<view>
		<u-form :model="form" label-width="fit-content">
			<u-form-item :label="type">
				<u-icon name="arrow-down-fill" @click="show1 = true"></u-icon>
				<u-select v-model="show1" :list="list1" @confirm="confirm1"></u-select>
				<u-input v-model="form.plateNo" placeholder="请输入车牌号"></u-input>
			</u-form-item>
			<u-form-item label="品牌种类">
				<u-icon name="arrow-down-fill" @click="show2 = true"></u-icon>
				<u-select v-model="show2" :list="list2" @confirm="confirm2"></u-select>
				<u-input v-model="form.type"></u-input>
			</u-form-item>
			<u-form-item label="发动机号">
				<u-input style="padding-left: 20rpx;" v-model="form.engineNo"></u-input>
			</u-form-item>
		</u-form>
		<button class="bu" @click="submit" style="margin-top: 50rpx;" :disabled="form.plateNo === '' || form.type === '' || form.engineNo === '' ? true : false">查询</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: '辽',
				list1: [
					{
						value: '1',
						label: '辽'
					},
					{
						value: '2',
						label: '京'
					}
				],
				list2: [
					{
						value: '1',
						label: '小型汽车'
					},
					{
						value: '2',
						label: '大型新能源汽车'
					},
					{
						value: '3',
						label: '大型汽车'
					},
					{
						value: '4',
						label: '小型新能源汽车'
					},
					{
						value: '5',
						label: '领管汽车'
					},
					{
						value: '6',
						label: '警用汽车'
					}
				],
				show1: false,
				show2: false,
				form:{
					plateNo: '',
					type: '',
					engineNo: ''
				}
			};
		},
		methods:{
			confirm1(e) {
				this.type = e[0].label
			},
			confirm2(e){
				this.form.type = e[0].label
			},
			submit(){
				this.form.plateNo = this.type + this.form.plateNo
				this.$request({
					url: '/prod-api/api/traffic/car',
					method: 'POST',
					data:{
						...this.form
					}
				}).then(res => {
					if(res.code === 200){
						uni.showToast({
							title:'查询成功'
						})
						setTimeout(() => {
							uni.navigateTo({
								url:'/pages/violation/violation'
							})
						}, 1000)
					}else{
						uni.showToast({
							title:res.msg,
							icon:'error'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
view{
	padding: 20rpx;
}
</style>
